var t = require("../../../../@babel/runtime/helpers/objectSpread2"), e = require("../../../../@babel/runtime/helpers/defineProperty"), a = getApp();

Component({
    properties: {
        show: {
            type: Boolean,
            value: !1
        },
        person_name: {
            type: String,
            value: ""
        },
        is_new: {
            type: Boolean,
            value: !1
        },
        cid: {
            type: [ Boolean, String ],
            value: "0"
        }
    },
    observers: {
        show: function(t, e) {
            this.setData({
                showCompany: t
            });
        }
    },
    pageLifetimes: {
        show: function() {
            this.getAgreement();
        }
    },
    data: {
        showCompany: !1,
        agreement: {},
        form: {
            name: "",
            org_code: "",
            legal_name: "",
            legal_idNo: "",
            org_type: "1"
        }
    },
    methods: {
        handlerInput: function(t) {
            var a = t.target.dataset.type;
            this.setData(e({}, "".concat(a), t.detail));
        },
        checkoutInfo: function() {
            var t = this;
            if (this.data.form.name) {
                var e = a.getNetAddresss("plugin.yun-sign.frontend.company.qccCheck");
                a._postNetWork({
                    url: e,
                    data: {
                        name: this.data.form.name
                    },
                    success: function(e) {
                        var a = e.data;
                        1 === a.result ? t.setData({
                            "form.org_code": a.data.org_code
                        }) : wx.showModal({
                            title: "提示",
                            content: a.msg,
                            showCancel: !1
                        });
                    },
                    fail: function(t) {
                        console.log(t, "----失败-----");
                    }
                });
            } else a.tips("请填写组织名称");
        },
        getAgreement: function() {
            var t = this, e = a.getNetAddresss("plugin.yun-sign.frontend.company.get-agreement");
            a._postNetWork({
                url: e,
                success: function(e) {
                    var a = e.data;
                    1 === a.result ? t.setData({
                        agreement: a.data
                    }) : wx.showModal({
                        title: "提示",
                        content: a.msg,
                        showCancel: !1
                    });
                },
                fail: function(t) {
                    console.log(t, "----失败-----");
                }
            });
        },
        hiddenPop: function() {
            this.setData({
                showCompany: !1
            });
        },
        sureIdentify: function() {
            this.data.form.legal_name ? this.data.form.legal_idNo ? this.data.form.org_type ? this.data.form.name ? this.data.form.org_code ? this.authRequest() : a.tips("请填写证件号") : a.tips("请填写组织名称") : a.tips("请选择证件号类型") : a.tips("请选择身份证") : a.tips("请填写姓名");
        },
        authRequest: function() {
            var e = a.getNetAddresss("plugin.yun-sign.frontend.h5.company.auth-company-v2"), o = t({}, this.data.form);
            this.properties.is_new || (o.cid = this.properties.cid), a._postNetWork({
                url: e,
                data: o,
                success: function(t) {
                    var e = t.data;
                    1 === e.result ? (a.tips(e.msg), this.triggerEvent("changeCid", {
                        cid: e.data.cid
                    }), this.hiddenPop()) : wx.showModal({
                        title: "提示",
                        content: e.msg,
                        showCancel: !1,
                        success: function() {}
                    });
                },
                fail: function(t) {
                    console.log(t, "----失败-----");
                }
            });
        }
    }
});